package com.sky.controller.user;

import com.sky.result.Result;
import com.sky.service.IDishService;
import com.sky.vo.DishVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController(value = "userDishController")
@RequestMapping("/user/dish")
public class DishController {
    @Autowired
    private IDishService dishService;

    /**
     * 微信用户点击某一个列表 弹出对应的套餐或者菜品
     * @param categoryId
     * @return
     */
    @Cacheable(value = "dishCache",key = "#categoryId")
    @GetMapping("/list")
    public Result<List<DishVo>> list(@RequestParam Long categoryId){
        List<DishVo> dishVos=dishService.dishesWithFlavor(categoryId);
        return Result.success(dishVos);
    }
}
